home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SGI Enlighten DSM 1.1
/
SGI EnlightenDSM 1.1.iso
/
hp10x
/
emd.z
/
emd
/
bin
/
postinstall_emd
< prev
next >
Wrap
Text File
|
1998-06-30
|
28KB
|
1,101 lines
#!/bin/sh
#
copyright="Copyright (c) 1990-1998 Enlighten Software Solutions, Inc."
#
# Post-installation of EMD and informix
#
# usage: $0 -f <informix-DB installation directory>
# -emdir <emd installation directory>
# -dbhome <dbenl home>
# -h displays usagse notes.
#-----------------------------------------------------------------------------
#
# Please note that the 'main' is at the bottom of this script.
# (grep for 'Start')
#
# TODO : Remove verbose_output default after debugging is done
#verbose_output="true"
#
# Start of functions
#
#
display_usage() {
echo
echo "$app_name facilitates post-installation of EMD and informixSE."
echo
echo "Usage: $app_name [-f <informixSE install dir>] \ "
echo " [-emddir <emd installation directory>] \ "
echo " [-dbhome <dbenl home>] \ "
echo " [-help] [-verbose]"
echo
echo "Note: -dbhome defaults to -emddir if no value is given."
echo " -emddir defaults to the emd_dir value stored in /etc/enlighten."
echo
echo $copyright
echo
}
error_check () {
if [ $? -ne 0 ] ; then
echo "$appName: Fatal: Could not successfully finish configuring EMD." 1>&2
exit 1
fi
}
set_constants () {
# Set umask
umask 077
# Pathnames to EnlightenDSM components
emd_binary=$emd_dir/bin/emdd
createdb_binary=$emd_dir/bin/CreateDb
dbaccess_binary=$informix_dir/bin/dbaccess
createdb_script=$emd_dir/.create_emd_tables.sh
dbaccess_input=$emd_dir/.dbaccess_input.txt
#
# These ID numbers are just the starting number -
# This script *does* ensure the ID is unique (for local, NIS, and NIS+)
#
informix_uid=1000
informix_gid=1000
informix_home=/
dbenl_uid=1001
ETCPASSWD=/etc/passwd
ETCSHADOW=/etc/shadow
ETCGROUP=/etc/group
INFXLIB=iasfs07a.so
case "$os_name" in
"HP-UX" )
VSIM=vsifmx7.sl
;;
"IRIX64" | "IRIX" | "SunOS" | "AIX" )
VSIM=vsifmx7.so.1
;;
"SCO_SV" )
VSIM=vsifmx5.so.1
;;
* )
echo "$app_name: EMD for $os_name release $os_release is not supported." 1>&2
exit 2
;;
esac
#
# Ensure EMD and CreateDb have a log directory to write to
#
if [ ! -d $emd_dir/logs ] ; then
mkdir -p $emd_dir/logs
chmod 700 $emd_dir/logs
error_check
fi
#-----------------------------------------------------------------------------
#
# Determine if NIS or NIS+ is running
#
unset nis_running
if [ -n "`ps $ps_opts | grep ypbind | grep -v grep`" ] ; then
#
# Ensure NIS is actually up and functional
#
ypcat passwd 2> /dev/null > $ypcat_passwd_output
if [ $? -ne 0 ] ; then
echo "$app_name: Host was found to be running ypbind, but 'ypcat passwd' failed."
else
ypcat group 2> /dev/null > $ypcat_group_output
if [ $? -ne 0 ] ; then
echo "$app_name: Host was found to be running ypbind, but 'ypcat group' failed."
else
nis_running="true"
if [ "$verbose_output" ] ; then
echo "$app_name: Host was found to be using NIS."
fi
fi
fi
fi
if [ -n "`ps $ps_opts | grep nis_cach | grep -v grep`" ] ; then
#
# Ensure NIS+ is actually up and functional
#
niscat passwd.org_dir 2> /dev/null > $niscat_passwd_output
if [ $? -ne 0 ] ; then
echo "$app_name: The NIS+ client daemon was up, but 'niscat passwd.org_dir' failed."
else
niscat group.org_dir 2> /dev/null > $niscat_group_output
if [ $? -ne 0 ] ; then
echo "$app_name: The NIS+ client daemon was up, but 'niscat group.org_dir' failed."
else
nis_plus_running="true"
if [ "$verbose_output" ] ; then
echo "$app_name: Host was found to be using NIS."
fi
fi
fi
fi
#-----------------------------------------------------------------------------
#
# Workaround for IRIX (and possibly other OSes).
#
# Informix gives a "25590: Authentication error." when the dbenl user
# or informix user is not in the local /etc/passwd file.
#
force_local_dbenl_user="true"
}
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#
# Add group 'informix', user 'informix', and user 'dbenl'.
#
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
add_informix_group () {
#-----------------------------------------------------------------------------
#
# See if group 'informix' is defined
#
unset informix_group_exists
if [ -n "`grep '^informix:' $ETCGROUP`" ] ; then
informix_group_exists="true"
informix_gid=`grep "^informix:" $ETCGROUP | cut '-d:' -f3`
if [ "$verbose_output" ] ; then
echo $app_name": group 'informix' (gid=$informix_gid) is already in $ETCGROUP"
fi
elif [ -z "$force_local_informix_group" -a "$nis_running" ] ; then
if [ -n "`grep '^informix:' $ypcat_group_output`" ] ; then
informix_group_exists="true"
informix_gid=`grep "^informix:" $ypcat_group_output | cut '-d:' -f3`
if [ "$verbose_output" ] ; then
echo "$app_name: group 'informix' (gid=$informix_gid) is already in NIS."
fi
fi
elif [ -z "$force_local_informix_group" -a "$nis_plus_running" ] ; then
if [ -n "`grep '^informix:' $niscat_group_output`" ] ; then
informix_group_exists="true"
informix_gid=`grep "^informix:" $niscat_group_output | cut '-d:' -f3`
if [ "$verbose_output" ] ; then
echo "$app_name: group 'informix' (gid=$informix_gid) is already in NIS+."
fi
fi
elif [ "$verbose_output" ] ; then
echo "$app_name: Group 'informix' does not exist."
fi
#-----------------------------------------------------------------------------
#
# Create the 'informix' group if necessary
#
if [ ! "$informix_group_exists" ] ; then
#
# Make a temporary file with all the current gid #s
# (using a temp file lets me only call ypcat or niscat once.)
#
cut '-d:' -f3 $ETCGROUP > $temp_file
error_check
if [ "$nis_running" ] ; then
cat $ypcat_group_output | cut '-d:' -f3 >> $temp_file
error_check
fi
if [ "$nis_plus_running" ] ; then
cat $niscat_group_output | cut '-d:' -f3 >> $temp_file
error_check
fi
# Now search through that file to find a unique id.
while [ -n "`fgrep -x $informix_gid $temp_file`" ] ; do
if [ "$verbose_output" ] ; then
echo "$app_name: 'informix' gid $informix_gid was not unique."
fi
informix_gid=`expr 1 + $informix_gid`
done
if [ "$verbose_output" ] ; then
echo "$app_name: 'informix' gid $informix_gid was found to be unique."
fi
# Backup $ETCGROUP
cp $ETCGROUP $ETCGROUP.orig
echo "$app_name: $ETCGROUP was archived to $ETCGROUP.orig"
# And add the entry to the start of $ETCGROUP
rm -f $temp_file
error_check
lineno=`grep -n "^+" $ETCGROUP | awk -F: '{print $1}'`
if [ $lineno ] ; then
sed -e ''${lineno}'i\
informix::'${informix_gid}':informix' $ETCGROUP > $temp_file
error_check
else
cat $ETCGROUP > $temp_file
error_check
echo 'informix::'${informix_gid}':informix' >> $temp_file
error_check
fi
if [ "$verbose_output" ] ; then
echo "$app_name: Moving the new group file into $ETCGROUP..."
fi
cp $temp_file $ETCGROUP
error_check
chmod 644 $ETCGROUP
error_check
rm -f $temp_file
error_check
echo "$app_name: Group 'informix' (gid=$informix_gid) was added successfully."
fi
}
add_informix_user () {
#-----------------------------------------------------------------------------
#
# See if user 'informix' is defined
#
unset informix_user_exists
if [ -n "`grep '^informix:' $ETCPASSWD`" ] ; then
informix_user_exists="true"
if [ "$verbose_output" ] ; then
echo $app_name": User 'informix' is already in $ETCPASSWD"
fi
elif [ -z "$force_local_informix_user" -a "$nis_running" ] ; then
if [ -n "`grep '^informix:' $ypcat_passwd_output`" ] ; then
informix_user_exists="true"
if [ "$verbose_output" ] ; then
echo "$app_name: User 'informix' is already in NIS"
fi
fi
elif [ -z "$force_local_informix_user" -a "$nis_plus_running" ] ; then
if [ -n "`grep '^informix:' $niscat_passwd_output`" ] ; then
informix_user_exists="true"
if [ "$verbose_output" ] ; then
echo "$app_name: User 'informix' is already in NIS+"
fi
fi
elif [ "$verbose_output" ] ; then
echo "$app_name: User 'informix' does not exist."
fi
#-----------------------------------------------------------------------------
#
# Create the 'informix' user account if necessary
#
if [ ! "$informix_user_exists" ] ; then
#
# Make a temporary file with all the current gid #s
# (using a temp file lets me only call ypcat or niscat once.)
#
cut '-d:' -f3 $ETCPASSWD > $temp_file
error_check
if [ "$nis_running" ] ; then
cat $ypcat_passwd_output | cut '-d:' -f3 >> $temp_file
error_check
fi
if [ "$nis_plus_running" ] ; then
cat $niscat_passwd_output | cut '-d:' -f3 >> $temp_file
error_check
fi
# Now search through that file to find a unique id.
while [ -n "`fgrep -x $informix_uid $temp_file`" ] ; do
if [ "$verbose_output" ] ; then
echo "$app_name: 'informix' uid $informix_uid was not unique."
fi
informix_uid=`expr 1 + $informix_uid`
done
if [ "$verbose_output" ] ; then
echo "$app_name: 'informix' uid $informix_uid was found to be unique."
fi
# Backup $ETCPASSWD
cp $ETCPASSWD $ETCPASSWD.orig
echo "$app_name: $ETCPASSWD was archived to $ETCPASSWD.orig"
# Make 'informix' such that only root can su informix
if [ "$os_name" = "AIX" -a -f /etc/security/passwd ] ; then
echo "informix:\!:$informix_uid:$informix_gid:Informix user:$informix_home:/bin/sh" \
> $temp_file
error_check
elif [ -f $ETCSHADOW ] ; then
echo "informix:x:$informix_uid:$informix_gid:Informix user:$informix_home:/bin/sh" \
> $temp_file
error_check
else
echo "informix:*:$informix_uid:$informix_gid:Informix user:$informix_home:/bin/sh" \
> $temp_file
error_check
fi
cat $ETCPASSWD >> $temp_file
error_check
if [ "$verbose_output" ] ; then
echo "$app_name: Moving the new passwd file into $ETCPASSWD..."
fi
cp $temp_file $ETCPASSWD
error_check
chmod 644 $ETCPASSWD
error_check
rm -f $temp_file
# Add the reference to the security file/shadow file
if [ "$os_name" = "AIX" -a -f /etc/security/passwd ] ; then
# Backup /etc/security/passwd
cp /etc/security/passwd /etc/security/passwd.orig
error_check
echo "$app_name: /etc/security/passwd was archived to /etc/security/passwd.orig"
# Add the passwd entry
echo "informix:\n\tpassword = *\n" > $temp_file
error_check
cat /etc/security/passwd >> $temp_file
error_check
if [ "$verbose_output" ] ; then
echo "$app_name: Copying in the new /etc/security/passwd file..."
fi
cp $temp_file /etc/security/passwd
error_check
if [ "$verbose_output" ] ; then
echo $app_name": AIX user 'informix' added to /etc/security/passwd."
fi
rm -f $temp_file
elif [ -f $ETCSHADOW ] ; then
# Backup /etc/shadow
cp -p $ETCSHADOW $ETCSHADOW.orig
error_check
echo "$app_name: $ETCSHADOW was archived to $ETCSHADOW.orig"
# Add the passwd entry
echo "informix:*:::" > $temp_file
error_check
cat $ETCSHADOW >> $temp_file
error_check
cp $temp_file $ETCSHADOW
error_check
if [ "$verbose_output" ] ; then
echo "$app_name: user 'informix' added to $ETCSHADOW."
fi
rm -f $temp_file
fi
echo $app_name": User 'informix' (uid="$informix_uid") added successfully."
fi
}
add_dbenl_user () {
#-----------------------------------------------------------------------------
#
# See if user 'dbenl' is defined
#
unset dbenl_user_exists
if [ -n "`grep '^dbenl:' $ETCPASSWD`" ] ; then
dbenl_user_exists="true"
if [ "$verbose_output" ] ; then
echo $app_name": User 'dbenl' is already in $ETCPASSWD"
fi
old_dbenl_home_dir=`grep "^dbenl:" $ETCPASSWD | cut '-d:' -f6`
elif [ -z "$force_local_dbenl_user" -a "$nis_running" ] ; then
if [ -n "`grep '^dbenl:' $ypcat_passwd_output" ] ; then
dbenl_user_exists="true"
if [ "$verbose_output" ] ; then
echo "$app_name: User 'dbenl' is already in NIS"
fi
old_dbenl_home_dir=`grep "^dbenl:" $ypcat_passwd_output | cut '-d:' -f6`
fi
elif [ -z "$force_local_dbenl_user" -a "$nis_plus_running" ] ; then
if [ -n "`grep '^dbenl:' $niscat_passwd_output`" ] ; then
dbenl_user_exists="true"
if [ "$verbose_output" ] ; then
echo "$app_name: User 'dbenl' is already in NIS+"
fi
old_dbenl_home_dir=`grep "^dbenl:" $niscat_passwd_output | cut '-d:' -f6`
fi
elif [ "$verbose_output" ] ; then
echo "$app_name: User 'dbenl' does not exist."
fi
if [ -n "$old_dbenl_home_dir" -a ! "$old_dbenl_home_dir" = "$emd_dir" ] ; then
#
# TODO: Upgrade code goes here. (Dump table, change dbenl_home
# entry is in /etc/passwd, and import table.)
#
echo "$app_name: A previously existing 'dbenl' home directory points to $old_dbenl_home_dir." 1>&2
echo "$app_name: Please deinstall on this host before reinstalling EMD." 1>&2
exit 1
fi
#-----------------------------------------------------------------------------
#
# Create the 'dbenl' user account if necessary
#
if [ ! "$dbenl_user_exists" ] ; then
#
# Make a temporary file with all the current gid #s
# (using a temp file lets me only call ypcat or niscat once.)
#
cut '-d:' -f3 $ETCPASSWD > $temp_file
error_check
if [ "$nis_running" ] ; then
cat $ypcat_passwd_output | cut '-d:' -f3 >> $temp_file
error_check
fi
if [ "$nis_plus_running" ] ; then
cat $niscat_passwd_output | cut '-d:' -f3 >> $temp_file
error_check
fi
# Now search through that file to find a unique id.
while [ -n "`fgrep -x $dbenl_uid $temp_file`" ] ; do
if [ "$verbose_output" ] ; then
echo "$app_name: 'dbenl' uid $dbenl_uid was not unique."
fi
dbenl_uid=`expr 1 + $dbenl_uid`
done
if [ "$verbose_output" ] ; then
echo "$app_name: 'dbenl' uid $dbenl_uid was found to be unique."
fi
# Backup $ETCPASSWD
cp $ETCPASSWD $ETCPASSWD.orig
echo "$app_name: $ETCPASSWD was archived to '$ETCPASSWD.orig'"
# Make 'dbenl' such that only root can su dbenl
if [ "$os_name" = "AIX" -a -f /etc/security/passwd ] ; then
echo "dbenl:\!:$dbenl_uid:$informix_gid:Informix user:$dbenl_home:/bin/sh" \
> $temp_file
error_check
elif [ -f $ETCSHADOW ] ; then
echo "dbenl:x:$dbenl_uid:$informix_gid:Informix user:$dbenl_home:/bin/sh" \
> $temp_file
error_check
else
echo "dbenl:*:$dbenl_uid:$informix_gid:Informix user:$dbenl_home:/bin/sh" \
> $temp_file
error_check
fi
cat $ETCPASSWD >> $temp_file
error_check
if [ "$verbose_output" ] ; then
echo "$app_name: Moving the new passwd file into $ETCPASSWD..."
fi
cp $temp_file $ETCPASSWD
error_check
chmod 644 $ETCPASSWD
error_check
rm -f $temp_file
# Add the reference to the security file/shadow file
if [ "$os_name" = "AIX" -a -f /etc/security/passwd ] ; then
# Backup /etc/security/passwd
cp /etc/security/passwd /etc/security/passwd.orig
error_check
echo "$app_name: /etc/security/passwd was archived to /etc/security/passwd.orig"
# Add the passwd entry
echo "dbenl:\n\tpassword = *\n" > $temp_file
error_check
cat /etc/security/passwd >> $temp_file
error_check
if [ "$verbose_output" ] ; then
echo "$app_name: Copying in the new /etc/security/passwd file..."
fi
cp $temp_file /etc/security/passwd
error_check
if [ "$verbose_output" ] ; then
echo $app_name": AIX user 'dbenl' added to /etc/security/passwd."
fi
rm -f $temp_file
elif [ -f $ETCSHADOW ] ; then
# Backup /etc/shadow
cp -p $ETCSHADOW $ETCSHADOW.orig
error_check
echo "$app_name: $ETCSHADOW was archived to $ETCSHADOW.orig"
# Add the passwd entry
echo "dbenl:*:::" > $temp_file
error_check
cat $ETCSHADOW >> $temp_file
error_check
cp $temp_file $ETCSHADOW
error_check
if [ "$verbose_output" ] ; then
echo "$app_name: user 'dbenl' added to $ETCSHADOW."
fi
rm -f $temp_file
fi
echo $app_name": User 'dbenl' (uid="$dbenl_uid") added successfully."
fi
}
create_emd_database () {
#-----------------------------------------------------------------------------
#
# Misc. permissions changing to dbenl and informix.
# Also get rid of old tables if they exist.
#
if [ ! -d $emd_dir/dbtables ] ; then
mkdir $emd_dir/dbtables
chmod 700 $emd_dir/dbtables
error_check
fi
if [ -d ${emd_dir}/dbtables/enlighten.dbs ] ; then
rm -fr ${emd_dir}/dbtables/enlighten.dbs
fi
if [ -f ${emd_dir}/dbtables/enlighten.log ] ; then
rm ${emd_dir}/dbtables/enlighten.log
fi
if [ ! -d $informix_dir ] ; then
echo "The Informix directory, $informix_dir, was missing." 1>&2
exit 3
fi
if [ ! -d $emd_dir/odbc ] ; then
echo "The odbc directory, $emd_dir/odbc, was missing." 1>&2
exit 3
fi
if [ ! -x $emd_binary ] ; then
if [ -f $emd_binary ] ; then
chmod u+x $emd_binary
else
echo "The EMD daemon, $emd_binary, was missing." 1>&2
exit 3
fi
fi
if [ ! -x $createdb_binary ] ; then
if [ -f $createdb_binary ] ; then
chmod u+x $createdb_binary
else
echo "The CreateDb utility, $createdb_binary, was missing." 1>&2
exit 3
fi
fi
chown -R dbenl $emd_dir
error_check
chown -R informix $informix_dir
error_check
chgrp -R informix $informix_dir
error_check
#-----------------------------------------------------------------------------
if [ -f $informix_dir/etc/sqlhosts ] ; then
echo "enl_se seipcpip `uname -n` sqlexec" > $temp_file
error_check
cat $informix_dir/etc/sqlhosts | grep -v enl_se >> $temp_file
error_check
cp $temp_file $informix_dir/etc/sqlhosts
error_check
rm -f $temp_file
fi
case "$os_name" in
"SunOS" )
if [ -f $informix_dir/lib/$INFXLIB ] ; then
if [ -f /usr/lib/$INFXLIB ] ; then
rm -f /usr/lib/$INFXLIB
error_check
fi
cp $informix_dir/lib/$INFXLIB /usr/lib
error_check
chmod a+r /usr/lib/$INFXLIB
error_check
else
echo "The Informix library, $informix_dir/lib/$INFXLIB, was not found." 1>&2
fi
;;
"AIX" )
for i in libasf.o netlib.o netstub.o libgen.o libos.o libsql.o ; do
if [ ! -f /usr/lib/$i ] ; then
cp $emd_dir/odbc/lib/$i /usr/lib
error_check
chmod a+r /usr/lib/$i
error_check
fi
done
;;
* )
;;
esac
#-----------------------------------------------------------------------------
# setup the odbc.ini file
if [ -f $dbenl_home/.odbc.ini ] ; then
mv $dbenl_home/.odbc.ini $dbenl_home/.odbc.ini.orig
fi
echo "[ODBC Data Source]" > $dbenl_home/.odbc.ini
echo "enl-informix=Informix Driver for Enlighten" >> $dbenl_home/.odbc.ini
echo >> $dbenl_home/.odbc.ini
echo "[ODBC]" >> $dbenl_home/.odbc.ini
echo "Trace=0" >> $dbenl_home/.odbc.ini
echo "InstallDir=$emd_dir/odbc" >> $dbenl_home/.odbc.ini
echo >> $dbenl_home/.odbc.ini
echo "[enl-informix]" >> $dbenl_home/.odbc.ini
echo "Driver=$emd_dir/odbc/drivers/$VSIM" >> $dbenl_home/.odbc.ini
echo "Database=enlighten" >> $dbenl_home/.odbc.ini
chown dbenl $dbenl_home/.odbc.ini
chmod 700 $dbenl_home/.odbc.ini
#-----------------------------------------------------------------------------
# setup the .profile
if [ -f $dbenl_home/.profile ] ; then
mv $dbenl_home/.profile $dbenl_home/.profile.orig
echo "$app_name: $dbenl_home/.profile was archived to $dbenl_home/.profile.orig."
fi
# assign $library_path_name and get the environment variable's setting -
# and if it isn't set, default to "/usr/lib".
case "$os_name" in
"HP-UX" )
libpath_name="SHLIB_PATH"
libpath=${SHLIB_PATH:-"/usr/lib"}
;;
"IRIX64" )
libpath_name="LD_LIBRARY_PATH"
libpath=${LD_LIBRARY_PATH:-""}
;;
"IRIX" | "SunOS" | "SCO_SV" )
libpath_name="LD_LIBRARY_PATH"
libpath=${LD_LIBRARY_PATH:-"/usr/lib"}
;;
"AIX" )
libpath_name="LIBPATH"
libpath=${LIBPATH:-"/usr/lib"}
;;
* )
echo "$app_name: No $library_path_name was defined."
;;
esac
libpath=$emd_dir/odbc/lib:$informix_dir/lib:$libpath
echo "umask 077" > $dbenl_home/.profile
echo "emd_dir=$emd_dir" >> $dbenl_home/.profile
echo "DBPATH=$emd_dir/dbtables ; export DBPATH" >> $dbenl_home/.profile
echo "INFORMIXDIR=$informix_dir ; export INFORMIXDIR" >> $dbenl_home/.profile
echo "INFORMIXSERVER=enl_se ; export INFORMIXSERVER" >> $dbenl_home/.profile
echo "ODBC=$emd_dir/odbc ; export ODBC" >> $dbenl_home/.profile
echo "LM_LICENSE_FILE=$emd_dir/FLEXlm/license.dat ; export LM_LICENSE_FILE" >> $dbenl_home/.profile
echo "HOME=$dbenl_home ; export HOME" >> $dbenl_home/.profile
echo "PATH=$informix_dir/bin:$PATH ; export PATH" >> $dbenl_home/.profile
echo "$libpath_name=$libpath ; export $libpath_name" >> $dbenl_home/.profile
echo "ENL_MCAT_DIR=$emd_dir/msg/C ; export ENL_MCAT_DIR" >> $dbenl_home/.profile
# ensure that dbaccess will run on IRIX
if [ "$os_name" = "IRIX" -o "$os_name" = "IRIX64" ]
then
echo "TERMCAP=$dbenl_home/informix/etc/termcap ; export TERMCAP" >> $dbenl_home/.profile
echo "TERM=vt100 ; export TERM" >> $dbenl_home/.profile
fi
chown dbenl $dbenl_home/.profile
chmod 700 $dbenl_home/.profile
echo "create database enlighten" > $dbaccess_input
error_check
echo "cd $emd_dir/dbtables" > $createdb_script
echo "$dbaccess_binary - - < $dbaccess_input" >> $createdb_script
#
# The AIX and IRIX dbaccess has a bug which leaves .seuser corrupt
# after it creates and writes to a db.
#
# The solution is to cat /dev/null into the $informix_dir/etc/.seuser file
# after dbaccess runs (and before createdb runs).
# If the database is created without logging enabled, then this bug appears
# anytime you disconnect from the database on IRIX only. So clear the file
# again after running CreateDb and after importing old database.
#
case "$os_name" in
"AIX" | "IRIX" | "IRIX64" )
echo "cat /dev/null > $informix_dir/etc/.seuser" >> $createdb_script
;;
* )
;;
esac
echo "cd $emd_dir/dbtables" >> $createdb_script
echo "$createdb_binary `uname -n` $upgrade" >> $createdb_script
case "$os_name" in
"IRIX" | "IRIX64" )
echo "cat /dev/null > $informix_dir/etc/.seuser" >> $createdb_script
;;
* )
;;
esac
echo "exit" >> $createdb_script
chown dbenl $createdb_script $dbaccess_input
chmod 700 $createdb_script
chmod 400 $dbaccess_input
export emd_dir createdb_script
( su - dbenl -c $createdb_script > $emd_dir/logs/createdb.log ) 2> $emd_dir/logs/createdb.err
#
# If 'Database created' is in createdb.err, all is good.
#
if [ -f $emd_dir/logs/createdb.err ] ; then
if [ "`grep '^Database created\.' $emd_dir/logs/createdb.err`" -a \
! "`grep '{error}' $emd_dir/logs/createdb.err`" ] ; then
cat $emd_dir/logs/createdb.err >> $emd_dir/logs/createdb.log
rm $emd_dir/logs/createdb.err
# Well, at least the DB was initialized okay...
else
echo "$app_name: Errors occurred while creating the dbtables:" 1>&2
cat $emd_dir/logs/createdb.err 1>&2
exit_code=1
fi
fi
#
# Make sure CreateDb was all good
#
if [ -f $emd_dir/dbtables/install.log ] ; then
if [ -n "`fgrep 'Table creations successfully completed' $emd_dir/dbtables/install.log`" ] ; then
echo "$app_name: The EMD database was successfully created."
else
echo "$app_name: Errors occurred from $createdb_binary:" 1>&2
cat $emd_dir/dbtables/install.log 1>&2
exit_code=1
fi
else
echo "$app_name: $createdb_binary was not run properly." 1>&2
exit_code=1
fi
#
# Reimport data from previous database if upgrade flag = 1
#
if [ "$upgrade" -eq 1 ] ; then
if [ ! -d ${emd_dir}/dbtables/enlighten.exp ] ; then
echo "$app_name: Unable to find enlighten.exp directory." 1>&2
echo "$app_name: Unable to restore EMD data." 1>&2
exit_code=1
fi
#
# Determine which dbload commands file to use. This depends on whether
# the exported database was using logging or not. The names of the
# exported files helps us deermine this
#
if [ -f ${emd_dir}/dbtables/enlighten.exp/pool_tb100.unl ] ; then
cmds_file="emd_dbload_cmds.nolog"
elif [ -f ${emd_dir}/dbtables/enlighten.exp/pool_tb101.unl ] ; then
cmds_file="emd_dbload_cmds"
else
cmds_file=""
echo "$app_name: Unable to determine which cmds file to use." 1>&2
echo "$app_name: Unable to restore EMD data." 1>&2
exit_code=1
fi
if [ ! -f ${emd_dir}/bin/${cmds_file} ] ; then
echo "$app_name: Unable to find $cmds_file file." 1>&2
echo "$app_name: Unable to restore EMD data." 1>&2
exit_code=1
fi
if [ "$exit_code" -ne 1 ] ; then
chmod u+w ${emd_dir}/dbtables/enlighten.exp
cp ${emd_dir}/bin/${cmds_file} ${emd_dir}/dbtables/enlighten.exp
chmod 500 ${emd_dir}/dbtables/enlighten.exp/${cmds_file}
su dbenl -c "cd ${emd_dir} ; . ./.profile; cd dbtables/enlighten.exp; dbload -c ${cmds_file} -d enlighten -l enl_dbload.log -e 100 1> tmp "
res=`echo $?`
if [ "${res}" -gt 0 ] ; then
echo "$app_name: Errors occured while restoring EMD data." 1>&2
echo "$app_name: See ${emd_dir}/dbtables/enlighten.exp/enl_dbload.log for details." 1>&2
exit_code=1
else
echo "$app_name: Successfully restored EMD data."
fi
# Take care of that irix bug that corrupts the .seuser file
case "$os_name" in
"IRIX" | "IRIX64" )
cat /dev/null > $informix_dir/etc/.seuser
;;
* )
;;
esac
fi
fi
}
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
# Start of postinstall_emd script
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
exit_code=0 ; export exit_code
PATH=/bin:/usr/bin:/etc:/usr/ucb:/usr/bsd:/usr/etc:$PATH ; export PATH
app_name=`basename $0`
temp_file=/tmp/$app_name.$$
ypcat_passwd_output=/tmp/$app_name.yp
ypcat_group_output=/tmp/$app_name.yg
niscat_passwd_output=/tmp/$app_name.np
niscat_group_output=/tmp/$app_name.ng
os_name=`uname -s`
os_release=`uname -r`
upgrade=0
#
# determine what ps options to use.
# All systems use "-e" expcept for
# SunOS 4.1.3 and 4.1.4 that use -auxww
#
ps_opts="-e"
if [ "$os_name" = "SunOS" ] ; then
case "$os_release" in
4.1.* )
ps_opts="-auxww" ;;
* ) ;;
esac
fi
#
# Parse the command line arguments
#
while [ "$#" -ne 0 ] ; do
case "$1" in
-h* )
display_usage
exit 1
;;
-f )
informix_dir=$2
shift
;;
-emd* )
emd_dir=$2
shift
;;
-dbhome )
dbenl_home=$2
shift
;;
-v* )
verbose_output="true"
;;
-upgrade )
upgrade=$2
shift
;;
* )
echo $app_name: Invalid argument: $1
;;
esac
shift
done
if [ -z "$emd_dir" ] ; then
emd_dir=`fgrep 'emd_dir=' /etc/enlighten | cut '-d=' -f2`
echo "$app_name: The EMD installation directory is defaulting to $emd_dir."
fi
if [ ! -d "$emd_dir" ] ; then
echo "$app_name: The EMD installation directory '$emd_dir' was missing." 1>&2
display_usage
exit 2
fi
if [ -z "$informix_dir" ] ; then
informix_dir=$emd_dir/informix
fi
if [ ! -d "$informix_dir" ] ; then
echo "$app_name: The Informix directory '$informix_dir' was missing." 1>&2
display_usage
exit 2
fi
if [ -z "$dbenl_home" ] ; then
dbenl_home=$emd_dir
fi
set_constants
add_informix_group
add_informix_user
add_dbenl_user
create_emd_database
rm -f $ypcat_passwd_output $ypcat_group_output \
$niscat_passwd_output $niscat_group_output 2> /dev/null > /dev/null
exit $exit_code